package reflect;

/**
 * 使用当前类测试反射机制
 */
@AutoRunClass //注解
public class Person {
    private String name;//新建一个私有变量姓名,
    private int age;//新建一个私有变量年龄
    public Person() {//默认构造方法
    }
    public Person(String name) {//带一个参数的构造方法
        this.name = name;//名字赋值, this.表示当前对象
    }
    public Person(String name, int age) {//带两个参数的构造方法
        this.name = name;//名字赋值, this.表示当前对象
        this.age = age;//年龄赋值, this.表示当前对象
    }
    @AutoRunMethod
    public void sayHello () {
        System.out.println(name+": 大家好!");
    }
    @AutoRunMethod(5)
    public void sayHi(){System.out.println(name+":Hi!");}
    @AutoRunMethod(4)
    public void doSome(){System.out.println(name+":做某事");}
    @AutoRunMethod(3)
    public void sleep(){System.out.println(name+":在睡觉");}
    @AutoRunMethod
    public void watchTV(){System.out.println(name+":看电视");}
    public void study(){System.out.println(name+":在学习");}
    public void eat(){System.out.println(name+":在吃饭");}
    public void playGame(){System.out.println(name+":玩游戏");}
    public void sing(){System.out.println(name+":在唱歌");}
    public void say(String info){System.out.println(name+":"+info);}
    public void say(String info,int count){
        for(int i=0;i<count;i++){
            System.out.println(name+":"+info);
        }
    }
    private void heHe(){
        System.out.println("我是Person的私有方法hehe()!");
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
